/* eslint-disable */
import { createApp } from 'vue';
import App from './App.vue';
import router from './router';

// 微前端生命周期
let app = null;

function render(props = {}) {
    const { container } = props;
    app = createApp(App);
    app.use(router);
    app.mount(container ? container.querySelector('#app') : '#app');
}

// 独立运行时
if (!window.__POWERED_BY_QIANKUN__) {
    render();
}else {
    __webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
}

export async function bootstrap() {
    console.log('[vue3-sub-app] bootstrap');
}

export async function mount(props) {
    console.log('[vue3-sub-app] mount', props);
    render(props);
}

export async function unmount() {
    console.log('[vue3-sub-app] unmount');
    app.unmount();
    app = null;
}
